############################
#
# Stage 1
# Package app
#
############################
FROM maven:3.6.3-openjdk-11 as build-stage

WORKDIR /app

COPY pom.xml /app
COPY settings.xml ~/.m2
# Download all required dependencies into one layer
# RUN  mvn install -Dmaven.test.skip=true
# Copy source code
COPY src /app/src
# Build application
#RUN mvn clean package -DskipTests
RUN  mvn install -Dmaven.test.skip=true
############################
#
# Stage 2
# Build service image
#
############################
FROM openjdk:11

WORKDIR /app

ENV PORT="8080"

EXPOSE $PORT

COPY docker-entrypoint.sh /usr/local/bin/

COPY --from=build-stage /app/target/*.jar app.jar

#ENTRYPOINT ["docker-entrypoint.sh"]

CMD ["java", "-jar", "app.jar"]
